import request from "@/plugins/axios";

export function searchFixedWarehousingList(params) {
    return request({
        url: "/api/asset/fixed/warehousing/page",
        method: "get",
        params
    });
}

/**
 * 通过id查询定资产入库信息
 */
export function assetStorageInformation(assetFixedWarehousingId) {
    return request({
        url: `/api/asset/fixed/warehousing/already/${assetFixedWarehousingId}`,
        method: "get"
    });
}

/**
 * 获取所有政府登记项目
 */
export function governmentRegistrationProject() {
    return request({
        url: "/api/asset/registration/all",
        method: "get"
    });
}

/**
 * 添加资产登记记录
 * @param formData
 */
export function addFixedWarehousing(formData) {
    return request({
        url: "/api/asset/fixed/warehousing",
        method: "PUT",
        data: formData
    });
}

/**
 * 校验资产名称唯一性(修改时)
 * @param path
 */
export function checkAssetNameByUpdate(assetName, assetFixedWarehousingId) {
    return request({
        url:
            "/api/asset/fixed/warehousing/check-assetName-update?assetName=" +
            assetName +
            "&assetFixedWarehousingId=" +
            assetFixedWarehousingId,
        method: "get"
    });
}

/**
 * 校验资产编码唯一性(修改时)
 * @param path
 */
export function checkAssetCodeByUpdate(assetCode, assetFixedWarehousingId) {
    return request({
        url:
            "/api/asset/fixed/warehousing/check-assetCode-update?assetCode=" +
            assetCode +
            "&assetFixedWarehousingId=" +
            assetFixedWarehousingId,
        method: "get"
    });
}

/**
 * 校验凭证号唯一性(修改时)
 * @param path
 */
export function checkVoucherNoByUpdate(voucherNo, assetFixedWarehousingId) {
    return request({
        url:
            "/api/asset/fixed/warehousing/check-voucherNo-update?voucherNo=" +
            voucherNo +
            "&assetFixedWarehousingId=" +
            assetFixedWarehousingId,
        method: "get"
    });
}

/**
 * 检查房源是否已经入库
 * @param voucherNo
 */
export function checkRoomId(roomId) {
    return request({
        url: "/api/asset/fixed/warehousing/check-roomId-add/" + roomId,
        method: "get"
    });
}

/**
 * 导出待入库列表
 * @param searchKeyword
 * @param currentPage
 * @param pageSize
 */
export function exportRegistration(params) {
    return request({
        url: "/api/asset/fixed/warehousing/export",
        method: "get",
        responseType: "blob",
        params
    });
}

/**
 * 下载模板
 */
export function downloadTemplate() {
    return request({
        url: "/api/asset/fixed/warehousing/download",
        method: "get",
        responseType: "blob"
    });
}

/**
 * 文件解析
 */
export function fileAnalysis(path) {
    return request({
        url: "/api/asset/fixed/warehousing/import?path=" + path,
        method: "get"
    });
}

/**
 * 导出异常记录
 * @param path
 */
export function exportErrorRecord(errorTableData) {
    return request({
        url: "/api/asset/fixed/warehousing/export-error-record",
        method: "post",
        data: errorTableData,
        responseType: "blob"
    });
}

// hxf-0921-未入库分页
export function warehousingPage(keyword, query) {
    return request({
        url: "/api/asset/fixed/warehousing/page?keyword=" + keyword,
        method: "get",
        params: query
    });
}
